package cn.com.cennavi.minelab.service.od.client;

import cn.com.cennavi.minelab.service.od.ODReadResultDataSampleFromDBPrx;
import cn.com.cennavi.minelab.service.od.ODReadResultDataSampleFromDBPrxHelper;
import cn.com.cennavi.minelab.service.od.ReadResultDataSampleFromDBInputParam;
import cn.com.cennavi.minelab.service.od.ReadResultDataSampleFromDBOutputResult;

public class ODReadResultDataSampleFromDBlClient {
	public static void main(String[] args) {
		int status = 0;
		Ice.Communicator ic = null;

		try {
			ic = Ice.Util.initialize(args);
			Ice.ObjectPrx base = ic.stringToProxy("ODReadResultDataSampleFromDB:default -p 10000");
			ODReadResultDataSampleFromDBPrx odReadResultDataSampleFromDB = ODReadResultDataSampleFromDBPrxHelper.checkedCast(base);

			if (odReadResultDataSampleFromDB == null) {
				throw new Error("Invalid Proxy");
			}
			//
			ReadResultDataSampleFromDBInputParam askData = new ReadResultDataSampleFromDBInputParam();
			askData.userID = "azkaban";
			askData.projectID = "odModel_odNum";
			askData.filePath = "hdfs://nujhadoop/test/minlab/od/azkaban_odModel_odNum_1488508675683";
			askData.topN = 10;
			//
			ReadResultDataSampleFromDBOutputResult output = odReadResultDataSampleFromDB.readData(askData);
			System.out.println(output.errCode);
			System.out.println(output.errMsg);
			System.out.println(output.resultDataID);
			System.out.println("------------------------");
			for (String data : output.sampleData) {
				System.out.println(data);
			}
			System.out.println("------------------------");
			System.out.println(new String(output.metadata));
			System.out.println("------------------------");

		} catch (Ice.LocalException e) {
			e.printStackTrace();
			status = 1;

		} catch (Exception e) {
			System.err.println(e.getMessage());
			status = 1;

		} finally {
			if (ic != null)
				ic.destroy();

		}

		System.exit(status);

	}
}
